package com.dk.strategy;

import com.dk.config.CodePart;
import com.dk.model.AutoCodePart;
import org.springframework.stereotype.Component;

@Component//将类注入到容器中
@CodePart(partType = "FIXCHAR")//给注解中注入属性,通过反射获取值
public class FixcharStrategy implements CodeStrategyHandler{
    /**
     *
     * @param part 传递过来的AutoCodePart 对象
     * @return
     *
     * 实现接口重写方法,在类中书写逻辑代码,目的是解耦合
     */
    @Override
    public StringBuffer code(AutoCodePart part) {
        StringBuffer buffer = new StringBuffer();
        //如果是固定字符,拼接字符串
        String fixCharacter = part.getFixCharacter();
        buffer.append(fixCharacter);
        return buffer;
    }
}
